package com.kuangstudy.common.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * ClassName: Demo3
 * date: 2021/07/14 19:13:58
 *
 * @author zlk
 */
public class Demo3 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date date = new Date();
        /*格式化时间date(把日期转为字符串)*/
        String format = sdf.format(date);
        System.out.println(format);
        /*解析(把字符串转为日期) source和sdf的pattern相匹配*/
        Date parse = sdf.parse("2021-07-14 19:23");
        System.out.println(parse);

    }
}
